﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ls.Utils
{
    public static class CryptoHelper
    {
        /// <summary>
        /// MD5加密
        /// </summary>
        /// <param name="source"></param>
        /// <returns></returns>
        public static string MD5(string source) {
            return BytesUtil.ToBase64(Md5CryptoUtil.Encrypt(BytesUtil.FromString(source)));
        }

        /// <summary>
        /// DES 加密
        /// </summary>
        /// <param name="source"></param>
        /// <returns></returns>
        public static string DESEncrypt(string source) {

            return BytesUtil.ToBase64(DesCryptoUtil.Encrypt(BytesUtil.FromString(source)));
        }

        /// <summary>
        /// DES 解密
        /// </summary>
        /// <param name="source"></param>
        /// <returns></returns>
        public static string DESDecrypt(string source)
        {

            return BytesUtil.ToString(DesCryptoUtil.Decrypt(BytesUtil.FromBase64(source)));
        }
    }
}
